﻿using System;
using System.Collections.Generic;
using Character;
using H;
using UnityEngine;

// Token: 0x02000217 RID: 535
public class H_ExpressionData
{
	// Token: 0x06000E9E RID: 3742 RVA: 0x0005B968 File Offset: 0x00059B68
	public H_ExpressionData(H_Expression owner, TextAsset loadList)
	{
		CustomDataListLoader customDataListLoader = new CustomDataListLoader();
		customDataListLoader.Load(loadList);
		int attributeNo = customDataListLoader.GetAttributeNo("状態");
		int attributeNo2 = customDataListLoader.GetAttributeNo("種類");
		int attributeNo3 = customDataListLoader.GetAttributeNo("目");
		int attributeNo4 = customDataListLoader.GetAttributeNo("口");
		int attributeNo5 = customDataListLoader.GetAttributeNo("目の開き");
		int attributeNo6 = customDataListLoader.GetAttributeNo("口の開き");
		for (int i = 0; i < customDataListLoader.GetDataNum(); i++)
		{
			string data = customDataListLoader.GetData(attributeNo, i);
			string data2 = customDataListLoader.GetData(attributeNo2, i);
			string text = customDataListLoader.GetData(attributeNo3, i);
			string text2 = customDataListLoader.GetData(attributeNo4, i);
			float eyeOpen = float.Parse(customDataListLoader.GetData(attributeNo5, i));
			float mouthOpen = float.Parse(customDataListLoader.GetData(attributeNo6, i));
			text = owner.EyeName(text);
			text2 = owner.MouthName(text2);
			if (data == "台詞")
			{
				H_ExpressionData.Data_Voice data3 = new H_ExpressionData.Data_Voice(data2, text, text2, eyeOpen, mouthOpen);
				this.AddVoiceData(data3);
			}
			else
			{
				this.CreateTypeData(data, data2, text, text2, eyeOpen, mouthOpen);
			}
		}
	}

	// Token: 0x06000E9F RID: 3743 RVA: 0x0005BAAC File Offset: 0x00059CAC
	private void CreateTypeData(string state, string type, string eyeType, string mouthType, float eyeOpen, float mouthOpen)
	{
		string[] array = state.Split(new char[]
		{
			','
		});
		for (int i = 0; i < array.Length; i++)
		{
			if (this.CheckCreateTypeData_Hit(type))
			{
				this.type_datas.Add(new H_ExpressionData.Data_Type(array[i], type + "アタリ", eyeType, mouthType, eyeOpen, mouthOpen));
				this.type_datas.Add(new H_ExpressionData.Data_Type(array[i], type + "ハズレ", eyeType, mouthType, eyeOpen, mouthOpen));
			}
			else if (this.CheckCreateTypeData_Badge(type))
			{
				this.type_datas.Add(new H_ExpressionData.Data_Type(array[i], type + "性癖あり", eyeType, mouthType, eyeOpen, mouthOpen));
				this.type_datas.Add(new H_ExpressionData.Data_Type(array[i], type + "性癖なし", eyeType, mouthType, eyeOpen, mouthOpen));
			}
			else
			{
				this.type_datas.Add(new H_ExpressionData.Data_Type(array[i], type, eyeType, mouthType, eyeOpen, mouthOpen));
			}
		}
	}

	// Token: 0x06000EA0 RID: 3744 RVA: 0x0005BBB0 File Offset: 0x00059DB0
	private bool CheckCreateTypeData_Hit(string state)
	{
		for (int i = 0; i < H_ExpressionData.TypeStrs_AddHit.Length; i++)
		{
			if (state == H_ExpressionData.TypeStrs_AddHit[i])
			{
				return true;
			}
		}
		return false;
	}

	// Token: 0x06000EA1 RID: 3745 RVA: 0x0005BBEC File Offset: 0x00059DEC
	private bool CheckCreateTypeData_Badge(string state)
	{
		for (int i = 0; i < H_ExpressionData.TypeStrs_AddBadge.Length; i++)
		{
			if (state == H_ExpressionData.TypeStrs_AddBadge[i])
			{
				return true;
			}
		}
		return false;
	}

	// Token: 0x06000EA2 RID: 3746 RVA: 0x0005BC28 File Offset: 0x00059E28
	private void AddVoiceData(H_ExpressionData.Data_Voice data)
	{
		if (!this.voice_datas.ContainsKey(data.voice))
		{
			this.voice_datas.Add(data.voice, new H_ExpressionData.Data_Voice_Set());
		}
		this.voice_datas[data.voice].Add(data);
	}

	// Token: 0x06000EA3 RID: 3747 RVA: 0x0005BC78 File Offset: 0x00059E78
	public H_ExpressionData.Data ChangeExpression(Human human, string voiceFile, H_Parameter param, float duration)
	{
		if (!this.voice_datas.ContainsKey(voiceFile))
		{
			return null;
		}
		H_ExpressionData.Data_Voice_Set data_Voice_Set = this.voice_datas[voiceFile];
		int no = UnityEngine.Random.Range(0, data_Voice_Set.Count);
		H_ExpressionData.Data data = data_Voice_Set[no];
		if (data != null)
		{
			human.ExpressionPlay(0, data.eyeType, duration);
			human.blink.LimitMax = data.eyeOpen * 0.01f;
			human.lipSync.RelaxOpen = data.mouthOpen * 0.01f;
			bool flag = param.UseMouth(human.sex);
			string name = H_ExpressionData.MouthNo(human, data, param);
			human.ExpressionPlay(1, name, duration);
			human.lipSync.Hold = (flag || human.Gag);
			human.head.ResetMouth(flag || human.Gag);
			TONGUE_TYPE tongueType = (!flag) ? TONGUE_TYPE.FACE : TONGUE_TYPE.BODY;
			human.SetTongueType(tongueType);
		}
		return data;
	}

	// Token: 0x06000EA4 RID: 3748 RVA: 0x0005BD70 File Offset: 0x00059F70
	public H_ExpressionData.Data ChangeExpression(Human human, H_Expression.TYPE type, H_Parameter param, float duration)
	{
		H_ExpressionData.Data data = null;
		List<H_ExpressionData.Data> list = new List<H_ExpressionData.Data>();
		H_Expression.STATE state = (H_Expression.STATE)0;
		H_Expression.STATE state2 = (H_Expression.STATE)0;
		if (human.sex == SEX.FEMALE)
		{
			Female female = human as Female;
			state = ((!female.IsFloped()) ? H_Expression.STATE.RESIST : H_Expression.STATE.FLIP);
			state2 = state;
			if (female.personality.ahe)
			{
				state2 = H_Expression.STATE.AHE;
			}
			else if (female.personality.weakness)
			{
				state2 = H_Expression.STATE.WEAKNESS;
			}
			else if (param.style != null && param.style.type == H_StyleData.TYPE.INSERT)
			{
				if ((param.style.detailFlag & 16) != 0 && female.personality.vaginaVirgin)
				{
					state2 |= H_Expression.STATE.PAIN;
				}
				if ((param.style.detailFlag & 32) != 0 && female.personality.analVirgin)
				{
					state2 |= H_Expression.STATE.PAIN;
				}
			}
		}
		foreach (H_ExpressionData.Data_Type data_Type in this.type_datas)
		{
			if (data_Type.state == state2 && data_Type.type == type)
			{
				list.Add(data_Type);
			}
		}
		if (state2 != state && list.Count == 0)
		{
			foreach (H_ExpressionData.Data_Type data_Type2 in this.type_datas)
			{
				if (data_Type2.state == state && data_Type2.type == type)
				{
					list.Add(data_Type2);
				}
			}
		}
		if (list.Count > 0)
		{
			int index = UnityEngine.Random.Range(0, list.Count);
			data = list[index];
		}
		if (data != null)
		{
			human.ExpressionPlay(0, data.eyeType, duration);
			human.blink.LimitMax = data.eyeOpen * 0.01f;
			human.lipSync.RelaxOpen = data.mouthOpen * 0.01f;
			bool flag = param.UseMouth(human.sex);
			string name = H_ExpressionData.MouthNo(human, data, param);
			human.ExpressionPlay(1, name, duration);
			human.lipSync.Hold = (flag || human.Gag);
			human.head.ResetMouth(flag || human.Gag);
			TONGUE_TYPE tongueType = (!flag) ? TONGUE_TYPE.FACE : TONGUE_TYPE.BODY;
			human.SetTongueType(tongueType);
		}
		else
		{
			GlobalData.Debug_LogError("没有合适的表情:" + state2);
		}
		return data;
	}

	// Token: 0x06000EA5 RID: 3749 RVA: 0x0005C028 File Offset: 0x0005A228
	private static string MouthNo(Human human, H_ExpressionData.Data data, H_Parameter param)
	{
		if (!param.UseMouth(human.sex))
		{
			return data.mouthType;
		}
		if (param.mouth == H_MOUTH.KISS)
		{
			return "Mouth_Kiss_a";
		}
		if (param.mouth == H_MOUTH.INMOUTH)
		{
			return "Mouth_Fera_a";
		}
		if (param.mouth == H_MOUTH.LICK)
		{
			return "Mouth_Name_new";
		}
		return data.mouthType;
	}

	// Token: 0x04000F49 RID: 3913
	private static readonly string[] StateStrs = new string[]
	{
		"抵抗",
		"豹変",
		"脱力",
		"アヘ",
		"抵抗痛がり",
		"豹変痛がり"
	};

	// Token: 0x04000F4A RID: 3914
	private static readonly H_Expression.STATE[] States = new H_Expression.STATE[]
	{
		H_Expression.STATE.RESIST,
		H_Expression.STATE.FLIP,
		H_Expression.STATE.WEAKNESS,
		H_Expression.STATE.AHE,
		(H_Expression.STATE)5,
		(H_Expression.STATE)6
	};

	// Token: 0x04000F4B RID: 3915
	private static readonly string[] TypeStrs = new string[]
	{
		"呼吸",
		"台詞",
		"喘ぎ台詞弱",
		"喘ぎ台詞強",
		"喘ぎ弱ハズレ",
		"喘ぎ弱アタリ",
		"喘ぎ強ハズレ",
		"喘ぎ強アタリ",
		"舐め弱性癖なし",
		"舐め弱性癖あり",
		"舐め強性癖なし",
		"舐め強性癖あり",
		"フェラ弱性癖なし",
		"フェラ弱性癖あり",
		"フェラ強性癖なし",
		"フェラ強性癖あり",
		"イラマ弱性癖なし",
		"イラマ弱性癖あり",
		"イラマ強性癖なし",
		"イラマ強性癖あり",
		"手コキ弱",
		"手コキ強",
		"挿入",
		"フェラ挿入",
		"イラマ挿入",
		"中出し性癖あり",
		"中出し性癖なし",
		"外出し性癖あり",
		"外出し性癖なし",
		"口内射精性癖あり",
		"口内射精性癖なし",
		"絶頂",
		"絶頂後呼吸",
		"中出し後呼吸",
		"外出し後呼吸",
		"抜き",
		"フェラ抜き",
		"イラマ抜き",
		"咳き込み",
		"飲み込み",
		"吐き出し",
		"口汁見せ"
	};

	// Token: 0x04000F4C RID: 3916
	private static readonly string[] TypeStrs_AddHit = new string[]
	{
		"喘ぎ弱",
		"喘ぎ強"
	};

	// Token: 0x04000F4D RID: 3917
	private static readonly string[] TypeStrs_AddBadge = new string[]
	{
		"舐め弱",
		"舐め強",
		"フェラ弱",
		"フェラ強",
		"イラマ弱",
		"イラマ強",
		"中出し",
		"外出し",
		"口内射精"
	};

	// Token: 0x04000F4E RID: 3918
	private List<H_ExpressionData.Data_Type> type_datas = new List<H_ExpressionData.Data_Type>();

	// Token: 0x04000F4F RID: 3919
	private Dictionary<string, H_ExpressionData.Data_Voice_Set> voice_datas = new Dictionary<string, H_ExpressionData.Data_Voice_Set>();

	// Token: 0x02000218 RID: 536
	public abstract class Data
	{
		// Token: 0x04000F50 RID: 3920
		public string eyeType;

		// Token: 0x04000F51 RID: 3921
		public string mouthType;

		// Token: 0x04000F52 RID: 3922
		public float eyeOpen;

		// Token: 0x04000F53 RID: 3923
		public float mouthOpen;
	}

	// Token: 0x02000219 RID: 537
	public class Data_Voice : H_ExpressionData.Data
	{
		// Token: 0x06000EA8 RID: 3752 RVA: 0x0005C2E0 File Offset: 0x0005A4E0
		public Data_Voice(string voice, string eyeType, string mouthType, float eyeOpen, float mouthOpen)
		{
			this.voice = voice;
			this.eyeType = eyeType;
			this.mouthType = mouthType;
			this.eyeOpen = eyeOpen;
			this.mouthOpen = mouthOpen;
		}

		// Token: 0x04000F54 RID: 3924
		public string voice;
	}

	// Token: 0x0200021A RID: 538
	private class Data_Voice_Set
	{
		// Token: 0x17000177 RID: 375
		public H_ExpressionData.Data_Voice this[int no]
		{
			get
			{
				return this.list[no];
			}
		}

		// Token: 0x17000178 RID: 376
		// (get) Token: 0x06000EAB RID: 3755 RVA: 0x0005C334 File Offset: 0x0005A534
		public int Count
		{
			get
			{
				return this.list.Count;
			}
		}

		// Token: 0x06000EAC RID: 3756 RVA: 0x0005C344 File Offset: 0x0005A544
		public void Add(H_ExpressionData.Data_Voice add)
		{
			this.list.Add(add);
		}

		// Token: 0x04000F55 RID: 3925
		private List<H_ExpressionData.Data_Voice> list = new List<H_ExpressionData.Data_Voice>();
	}

	// Token: 0x0200021B RID: 539
	public class Data_Type : H_ExpressionData.Data
	{
		// Token: 0x06000EAD RID: 3757 RVA: 0x0005C354 File Offset: 0x0005A554
		public Data_Type(string state, string type, string eyeType, string mouthType, float eyeOpen, float mouthOpen)
		{
			this.state = H_ExpressionData.Data_Type.CheckState(state);
			this.type = H_ExpressionData.Data_Type.CheckType(type);
			this.eyeType = eyeType;
			this.mouthType = mouthType;
			this.eyeOpen = eyeOpen;
			this.mouthOpen = mouthOpen;
		}

		// Token: 0x06000EAE RID: 3758 RVA: 0x0005C394 File Offset: 0x0005A594
		private static H_Expression.STATE CheckState(string str)
		{
			H_Expression.STATE result = (H_Expression.STATE)0;
			int i;
			for (i = 0; i < H_ExpressionData.StateStrs.Length; i++)
			{
				if (str == H_ExpressionData.StateStrs[i])
				{
					result = H_ExpressionData.States[i];
					break;
				}
			}
			if (i == H_ExpressionData.StateStrs.Length)
			{
				GlobalData.Debug_LogError("不明状态:" + str);
			}
			return result;
		}

		// Token: 0x06000EAF RID: 3759 RVA: 0x0005C3F8 File Offset: 0x0005A5F8
		private static H_Expression.TYPE CheckType(string str)
		{
			for (int i = 0; i < H_ExpressionData.TypeStrs.Length; i++)
			{
				if (str == H_ExpressionData.TypeStrs[i])
				{
					return (H_Expression.TYPE)i;
				}
			}
			GlobalData.Debug_LogError("不明种类:" + str);
			return H_Expression.TYPE.NUM;
		}

		// Token: 0x04000F56 RID: 3926
		public H_Expression.STATE state;

		// Token: 0x04000F57 RID: 3927
		public H_Expression.TYPE type;
	}
}
